package com.huawei.appgallery.assistantdock.buoydock.card.node;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import com.huawei.appgallery.assistantdock.base.cardkit.card.BuoyBaseCard;
import com.huawei.appgallery.assistantdock.base.cardkit.node.BuoyBaseNode;
import com.huawei.appgallery.assistantdock.buoydock.card.bean.BuoyLanternCardBeanBuoy;
import com.huawei.appgallery.assistantdock.buoydock.card.bean.BuoyLanternItem;
import com.huawei.appgallery.assistantdock.buoydock.card.card.BuoyLanternCardBuoy;
import com.huawei.appgallery.assistantdock.buoydock.card.card.BuoyLanternItemCardBuoy;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import java.util.ArrayList;
import java.util.List;
import o.beo$a;
import o.beo$e;
import o.beo$j;
import o.cgz;
import o.chy;
import o.chz;
import o.cih;
import o.CollectCheck;

public class BuoyLanternNodeBuoy extends BuoyBaseNode {
    private BuoyLanternCardBuoy ˊ = null;
    private BuoyLanternCardBeanBuoy ॱॱ = null;

    public BuoyLanternNodeBuoy(Context context) {
        super(context);
    }

    public boolean ˊ(ViewGroup viewGroup, ViewGroup viewGroup2) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
        layoutParams.weight = 1.0f;
        LayoutInflater from = LayoutInflater.from(this.ॱ);
        this.ˊ = new BuoyLanternCardBuoy(this.ॱ);
        LinearLayout linearLayout = (LinearLayout) from.inflate(beo$j.ˊॱ, null);
        this.ˊ.ˋ(linearLayout);
        ˊ(this.ˊ);
        viewGroup.addView(linearLayout, layoutParams);
        return true;
    }

    public boolean ॱ(chz o_chz, ViewGroup viewGroup) {
        int ˏ = ˏ();
        this.ˏ = o_chz.ˏ;
        for (int i = 0; i < ˏ; i++) {
            cih ˎ = ˎ(i);
            if (ˎ instanceof BuoyLanternCardBuoy) {
                BuoyLanternCardBuoy buoyLanternCardBuoy = (BuoyLanternCardBuoy) ˎ;
                CardBean ˋ = o_chz.ˋ(i);
                if (ˋ instanceof BuoyLanternCardBeanBuoy) {
                    ˋ.ˋˋ(String.valueOf(this.ˏ));
                    this.ॱॱ = (BuoyLanternCardBeanBuoy) ˋ;
                    List ˊ = this.ॱॱ.ˊ();
                    if (CollectCheck.isEmpty(ˊ)) {
                        ˎ.ˉ().setVisibility(8);
                    } else {
                        ˋ(buoyLanternCardBuoy, ˊ.size(), 1);
                        buoyLanternCardBuoy.ˋ("BuoyLanternNodeBuoy");
                        buoyLanternCardBuoy.ˏ(ˋ);
                        ˎ.ˉ().setVisibility(0);
                    }
                } else {
                    ˎ.ˉ().setVisibility(8);
                }
            }
        }
        return true;
    }

    public void ˋ(chy o_chy) {
        cgz ˊ = ˊ(0);
        if (ˊ instanceof BuoyLanternCardBuoy) {
            ((BuoyLanternCardBuoy) ˊ).ॱ(o_chy);
        }
    }

    private void ˋ(BuoyLanternCardBuoy buoyLanternCardBuoy, int i, int i2) {
        buoyLanternCardBuoy.ˊ();
        View ˉ = buoyLanternCardBuoy.ˉ();
        ViewGroup viewGroup = (ViewGroup) ˉ.findViewById(beo$e.ʿ);
        ViewGroup viewGroup2 = (ViewGroup) ˉ.findViewById(beo$e.ʽॱ);
        viewGroup.removeAllViews();
        viewGroup2.removeAllViews();
        if (i <= 3) {
            ˋ(i, viewGroup);
            viewGroup2.setVisibility(8);
            return;
        }
        ˋ(i % 3, viewGroup);
        ˋ(3, viewGroup2);
    }

    private void ˋ(int i, ViewGroup viewGroup) {
        LayoutInflater from = LayoutInflater.from(this.ॱ);
        for (int i2 = 0; i2 < i; i2++) {
            if (i < 3) {
                View view = (ViewGroup) from.inflate(beo$j.ͺ, null);
            } else {
                ViewGroup viewGroup2 = (ViewGroup) from.inflate(beo$j.ˋॱ, null);
            }
            LayoutParams layoutParams = new LinearLayout.LayoutParams(0, -1);
            if (i2 > 0) {
                layoutParams.setMarginStart(this.ॱ.getResources().getDimensionPixelSize(beo$a.ˊ));
            }
            layoutParams.weight = 1.0f;
            if (view != null) {
                int ˋ = ˋ();
                view.setPadding(ˋ, 0, ˋ, 0);
                BuoyBaseCard buoyLanternItemCardBuoy = new BuoyLanternItemCardBuoy(this.ॱ);
                buoyLanternItemCardBuoy.ˏ(view);
                this.ˊ.ˎ(buoyLanternItemCardBuoy);
                viewGroup.addView(view, layoutParams);
            }
        }
    }

    private int ˋ() {
        return 0;
    }

    public boolean ॱ() {
        return true;
    }

    public ArrayList<String> z_() {
        if (this.ॱॱ == null) {
            return null;
        }
        ArrayList<String> arrayList = new ArrayList();
        List ˊ = this.ॱॱ.ˊ();
        if (ˊ == null) {
            return null;
        }
        for (int i = 0; i < ˊ.size(); i++) {
            BuoyLanternItem buoyLanternItem = (BuoyLanternItem) ˊ.get(i);
            if (buoyLanternItem != null) {
                arrayList.add(buoyLanternItem.ॱॱ() + "#$#" + buoyLanternItem.u_());
            }
        }
        return arrayList;
    }
}
